import { FormRule } from 'tdesign-vue-next';
import { ref } from 'vue';

export const INIT_DATA: any = { sn: '', dev_name: '', time: [] };

export const list = ref([
  { label: '设备序列号', value: '', key: 'sn', type: 'InputView', placeholder: '请输入设备序列号', clearable: true },
  { label: '设备名称', value: '', key: 'dev_name', type: 'InputView', placeholder: '请输入设备名称', clearable: true },
  { label: 'GA1400', value: true, key: 'ga1400', type: 'SwitchView' },
  { label: 'IP地址', value: '', key: 'ip', type: 'IPAddressView', placeholder: '' },
  {
    label: '时间',
    value: [],
    key: 'time',
    type: 'DateRangePickerView',
    placeholder: '',
    disableDate: { before: new Date() },
  },
  {
    label: '时间2',
    value: '',
    key: 'date',
    type: 'DatePickerView',
    placeholder: '',
    disableDate: { after: new Date() },
  },
  {
    label: '设备地址',
    value: {},
    key: 'address',
    type: 'AddressCascaderView',
    cascader: { placeholder: '请选择设备地址', clearable: true },
    input: { placeholder: '请填写设备详细地址', clearable: true },
  },
  {
    label: '用户名',
    value: '',
    key: 'name',
    type: 'EditInputView',
    placeholder: '请输入设备名称',
    saveValue: 'asd',
    inputType: 'password',
  },
  { label: '自定义表单', value: '', key: 'self_name', slot: true },
]);

export const FORM_RULES: Record<string, FormRule[]> = {
  sn: [{ required: true, message: '请输入设备序列号', trigger: 'blur' }],
  dev_name: [{ required: true, message: '请输入设备名称', trigger: 'blur' }],
};
